package com.avetti.commerce.webservices;

import java.io.Serializable;
import java.util.Date;

/**
 * @author S.Seleznev
 *
 */
public class Inventory implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    
    /** identifier field */
    private Long inventoryid;

    /** nullable persistent field */
    private String code = "";

    /** nullable persistent field */
    private Long itemid;

    /** persistent field */
    private long instock=0;

    /** persistent field */
    private long onorder=0;

    /** nullable persistent field */
    private String subcode="NOCODE";

    /** persistent field */
    private String vendorid="";

    /** nullable persistent field */
    private String attributes = "";

    /** nullable persistent field */
    private String options = "";

    /** nullable persistent field */
    private Short upd=new Short((short) 0);

    /** persistent field */
    private short fullupdate=0;

    /** persistent field */
    private short currentupdate=0;

    /** nullable persistent field */
    private Date lastoutofstock;

    /** nullable persistent field */
    private Date lastinstock;

    /** persistent field */
    private int pickpackdays=0;

    /** persistent field */
    private int nextshipqty=0;

    /** persistent field */
    private Date nextshipdate;

    /** persistent field */
    private int dropshipminqty=0;

    /** persistent field */
    private int dropshipdays=0;

    /** persistent field */
    private int minreorderqty=0;
    
    /** true -- NOT show the inventory value on item page*/
    private boolean hide=false;
    
    //Show Delivery Date Feature on Basket
    private boolean enableEditDeliveryDate=false;
    
    private boolean discontinued;
    
    private boolean thirdpartyinventory;
    
    private String thirdpartycode;

    /* below fields are used for control purpose, not exposed */
    private boolean inventoryidUpdated = false;
    private boolean codeUpdated = false;
    private boolean itemidUpdated = false;

    private boolean instockUpdated = false;
    private boolean onorderUpdated = false;
    private boolean subcodeUpdated = false;
    private boolean attributesUpdated = false;
    private boolean optionsUpdated = false;
    private boolean updUpdated = false;
    private boolean fullupdateUpdated = false;
    private boolean currentupdateUpdated = false;
    private boolean lastoutofstockUpdated = false;
    private boolean lastinstockUpdated = false;
    private boolean pickpackdaysUpdated = false;
    private boolean nextshipqtyUpdated = false;
    private boolean nextshipdateUpdated = false;
    private boolean dropshipminqtyUpdated = false;
    private boolean dropshipdaysUpdated = false;
    private boolean minreorderqtyUpdated = false;
    private boolean hideUpdated = false;
    private boolean enableEditDeliveryDateUpdated = false;
    private boolean defaultDeliveryUpdated = false;
    private boolean discontinuedUpdated =  false;
    private boolean thirdpartyinventoryUpdated = false;
    private boolean thirdpartycodeUpdated = false;

    private int defdelivery;
    
    private int minorderqty;
    
    public int getDefdelivery() {
        return defdelivery;
    }

    public void setDefdelivery(int defdelivery) {
        this.defdelivery = defdelivery;
        this.defaultDeliveryUpdated = true;
    }
    /**
     * @param inventoryidUpdated the inventoryidUpdated to set
     */
    public void setInventoryidUpdated(boolean inventoryidUpdated) {
        this.inventoryidUpdated = inventoryidUpdated;
    }

    /**
     * @param codeUpdated the codeUpdated to set
     */
    public void setCodeUpdated(boolean codeUpdated) {
        this.codeUpdated = codeUpdated;
    }

    /**
     * @param itemidUpdated the itemidUpdated to set
     */
    public void setItemidUpdated(boolean itemidUpdated) {
        this.itemidUpdated = itemidUpdated;
    }

    /**
     * @return the inventoryid
     */
    public Long getInventoryid() {
        return inventoryid;
    }

    /**
     * @param inventoryid the inventoryid to set
     */
    public void setInventoryid(Long inventoryid) {
        this.inventoryid = inventoryid;
        this.inventoryidUpdated = true;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
        this.codeUpdated = true;;
    }

    /**
     * @return the itemid
     */
    public Long getItemid() {
        return itemid;
    }

    /**
     * @param itemid the itemid to set
     */
    public void setItemid(Long itemid) {
        this.itemid = itemid;
        this.itemidUpdated = true;
    }

    /**
     * @return the instock
     */
    public long getInstock() {
        return instock;
    }

    /**
     * @param instock the instock to set
     */
    public void setInstock(long instock) {
        this.instock = instock;
        this.instockUpdated = true;
    }
    
    public boolean isInstockUpdated(){
        return this.instockUpdated;
    }

    /**
     * @return the onorder
     */
    public long getOnorder() {
        return onorder;
    }

    /**
     * @param onorder the onorder to set
     */
    public void setOnorder(long onorder) {
        this.onorder = onorder;
        this.onorderUpdated = true;
    }

    /**
     * @return the subcode
     */
    public String getSubcode() {
        return subcode;
    }

    /**
     * @param subcode the subcode to set
     */
    public void setSubcode(String subcode) {
        this.subcode = subcode;
        this.subcodeUpdated = true;
    }

    /**
     * @return the vendorid
     */
    public String getVendorid() {
        return vendorid;
    }

    /**
     * @param vendorid the vendorid to set
     */
    public void setVendorid(String vendorid) {
        this.vendorid = vendorid;
    }

    /**
     * @return the attributes
     */
    public String getAttributes() {
        return attributes;
    }

    /**
     * @param attributes the attributes to set
     */
    public void setAttributes(String attributes) {
        this.attributes = attributes;
        this.attributesUpdated = true;
    }

    /**
     * @return the options
     */
    public String getOptions() {
        return options;
    }

    /**
     * @param options the options to set
     */
    public void setOptions(String options) {
        this.options = options;
        this.optionsUpdated = true;
    }

    /**
     * @return the upd
     */
    public Short getUpd() {
        return upd;
    }

    /**
     * @param upd the upd to set
     */
    public void setUpd(Short upd) {
        this.upd = upd;
        this.updUpdated = true;
    }

    /**
     * @return the fullupdate
     */
    public short getFullupdate() {
        return fullupdate;
    }

    /**
     * @param fullupdate the fullupdate to set
     */
    public void setFullupdate(short fullupdate) {
        this.fullupdate = fullupdate;
        this.fullupdateUpdated = true;
    }

    /**
     * @return the currentupdate
     */
    public short getCurrentupdate() {
        return currentupdate;
    }

    /**
     * @param currentupdate the currentupdate to set
     */
    public void setCurrentupdate(short currentupdate) {
        this.currentupdate = currentupdate;
        this.currentupdateUpdated = true;
    }

    /**
     * @return the lastoutofstock
     */
    public Date getLastoutofstock() {
        return lastoutofstock;
    }

    /**
     * @param lastoutofstock the lastoutofstock to set
     */
    public void setLastoutofstock(Date lastoutofstock) {
        this.lastoutofstock = lastoutofstock;
        this.lastoutofstockUpdated = true;
    }

    /**
     * @return the lastinstock
     */
    public Date getLastinstock() {
        return lastinstock;
    }

    /**
     * @param lastinstock the lastinstock to set
     */
    public void setLastinstock(Date lastinstock) {
        this.lastinstock = lastinstock;
        this.lastinstockUpdated = true;
    }

    /**
     * @return the pickpackdays
     */
    public int getPickpackdays() {
        return pickpackdays;
    }

    /**
     * @param pickpackdays the pickpackdays to set
     */
    public void setPickpackdays(int pickpackdays) {
        this.pickpackdays = pickpackdays;
        this.pickpackdaysUpdated = true;
    }

    /**
     * @return the nextshipqty
     */
    public int getNextshipqty() {
        return nextshipqty;
    }

    /**
     * @param nextshipqty the nextshipqty to set
     */
    public void setNextshipqty(int nextshipqty) {
        this.nextshipqty = nextshipqty;
        this.nextshipqtyUpdated = true;
    }

    /**
     * @return the nextshipdate
     */
    public Date getNextshipdate() {
        return nextshipdate;
    }

    /**
     * @param nextshipdate the nextshipdate to set
     */
    public void setNextshipdate(Date nextshipdate) {
        this.nextshipdate = nextshipdate;
        this.nextshipdateUpdated = true;
    }

    /**
     * @return the dropshipminqty
     */
    public int getDropshipminqty() {
        return dropshipminqty;
    }

    /**
     * @param dropshipminqty the dropshipminqty to set
     */
    public void setDropshipminqty(int dropshipminqty) {
        this.dropshipminqty = dropshipminqty;
        this.dropshipminqtyUpdated = true;
    }

    /**
     * @return the dropshipdays
     */
    public int getDropshipdays() {
        return dropshipdays;
    }

    /**
     * @param dropshipdays the dropshipdays to set
     */
    public void setDropshipdays(int dropshipdays) {
        this.dropshipdays = dropshipdays;
        this.dropshipdaysUpdated = true;
    }

    /**
     * @return the minreorderqty
     */
    public int getMinreorderqty() {
        return minreorderqty;
    }

    /**
     * @param minreorderqty the minreorderqty to set
     */
    public void setMinreorderqty(int minreorderqty) {
        this.minreorderqty = minreorderqty;
        this.minreorderqtyUpdated = true;
    }

    /**
     * @return the hide
     */
    public boolean isHide() {
        return hide;
    }

    /**
     * @param hide the hide to set
     */
    public void setHide(boolean hide) {
        this.hide = hide;
        this.hideUpdated = true;
    }

    /**
     * @return the enableEditDeliveryDate
     */
    public boolean isEnableEditDeliveryDate() {
        return enableEditDeliveryDate;
    }

    /**
     * @param enableEditDeliveryDate the enableEditDeliveryDate to set
     */
    public void setEnableEditDeliveryDate(boolean enableEditDeliveryDate) {
        this.enableEditDeliveryDate = enableEditDeliveryDate;
        this.enableEditDeliveryDateUpdated = true;
    }

    private boolean enableMinorderqtyUpdated = false;
    public int getMinorderqty() {
        return minorderqty;
    }

    public void setMinorderqty(int minorderqty) {
        this.minorderqty = minorderqty;
        this.enableMinorderqtyUpdated = true;
    }

    public com.avetti.commerce.domainmodel.Inventory createUpdatedInventory(
            com.avetti.commerce.domainmodel.Inventory domainInventory) {

        if (defaultDeliveryUpdated)
            domainInventory.setDefdelivery(this.defdelivery);
        
        if (inventoryidUpdated) {
            domainInventory.setInventoryid(this.inventoryid);
        }

        if (codeUpdated) {
            domainInventory.setCode(this.code);
        }

        if (itemidUpdated) {
            domainInventory.setItemid(this.itemid);
        }

        if (instockUpdated) {
            domainInventory.setInstock(this.instock);
        }

        if (onorderUpdated) {
            domainInventory.setOnorder(this.onorder);
        }

        if (subcodeUpdated) {
            domainInventory.setSubcode(this.subcode);
        }

        if (attributesUpdated) {
            domainInventory.setAttributes(this.attributes);
        }

        if (optionsUpdated) {
            domainInventory.setOptions(this.options);
        }

        if (updUpdated) {
            domainInventory.setUpd(this.upd);
        }

        if (fullupdateUpdated) {
            domainInventory.setFullupdate(this.fullupdate);
        }

        if (currentupdateUpdated) {
            domainInventory.setCurrentupdate(this.currentupdate);
        }

        if (lastoutofstockUpdated) {
            domainInventory.setLastoutofstock(this.lastoutofstock);
        }

        if (lastinstockUpdated) {
            domainInventory.setLastinstock(this.lastinstock);
        }

        if (pickpackdaysUpdated) {
            domainInventory.setPickpackdays(this.pickpackdays);
        }

        if (nextshipqtyUpdated) {
            domainInventory.setNextshipqty(this.nextshipqty);
        }

        if (nextshipdateUpdated) {
            domainInventory.setNextshipdate(this.nextshipdate);
        }

        if (dropshipminqtyUpdated) {
            domainInventory.setDropshipminqty(this.dropshipminqty);
        }

        if (dropshipdaysUpdated) {
            domainInventory.setDropshipdays(this.dropshipdays);
        }

        if (minreorderqtyUpdated) {
            domainInventory.setMinreorderqty(this.minreorderqty);
        }

        if (hideUpdated) {
            domainInventory.setHide(this.hide);
        }

        if (enableEditDeliveryDateUpdated) {
            domainInventory.setEnableEditDeliveryDate(this.enableEditDeliveryDate);
        }
        if (enableMinorderqtyUpdated) {
            domainInventory.setMinorderqty(this.minorderqty);
        }
        
        if(discontinuedUpdated){
            domainInventory.setDiscontinued(this.discontinued);
        }
        
        if(thirdpartyinventoryUpdated){
            domainInventory.setThirdpartyinventory(this.thirdpartyinventory);
        }
        
        if(thirdpartycodeUpdated){
            domainInventory.setThirdpartycode(this.thirdpartycode);
        }

        return domainInventory;
    }

    /**
     * @return the discontinued
     */
    public boolean isDiscontinued() {
        return discontinued;
    }

    /**
     * @param discontinued the discontinued to set
     */
    public void setDiscontinued(boolean discontinued) {
        this.discontinued = discontinued;
        this.discontinuedUpdated = true;
    }

    /**
     * @return the thirdpartyinventory
     */
    public boolean isThirdpartyinventory() {
        return thirdpartyinventory;
    }

    /**
     * @param thirdpartyinventory the thirdpartyinventory to set
     */
    public void setThirdpartyinventory(boolean thirdpartyinventory) {
        this.thirdpartyinventory = thirdpartyinventory;
        this.thirdpartyinventoryUpdated = true;
    }

    /**
     * @return the thirdpartycode
     */
    public String getThirdpartycode() {
        return thirdpartycode;
    }

    /**
     * @param thirdpartycode the thirdpartycode to set
     */
    public void setThirdpartycode(String thirdpartycode) {
        this.thirdpartycode = thirdpartycode;
        this.thirdpartycodeUpdated = true;
    }   
}
